<?php
session_start() ;
if(!isset($_SESSION["login"]) || $_SESSION["login"] == "")
{   
  header("Location: index.php?error=4") ;
}?>

<html>
<head>
<title>Administration</title>
 <link rel="stylesheet" type="text/css" href="style.css" >  
</head>

<body>
<?php require("menu.php");
require("fonctions.php");
$code=$_GET["error"];
?>
<p class="titre">Liste des &eacute;tablissements</p>
<br></br>
<?php echo error_message($code);?>
<br>
<form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post"id="chg_enq" name="chg_f">
<table align="center">
<tr>
	<td colspan="2" align=center><a class="bouton" href="dis_contacts.php?action=new_dis&cur=3">Ajouter ETABLISSEMENT</a> </td>

</tr>
</table>
<br>
<table class="tab_dis" align="center">
<?php 
$id_user=$_SESSION["id_user"];	

 $sql="select * from distributeurs 
join asso_dis_man on id_distrib=id
where id_man=$id_user";
	$res = mysql_query($sql);
		
?>
<tr>
	<td class="tab_dis_head">CODESAP</td>
	<td class="tab_dis_head">NOM</td>
	<td class="tab_dis_head">GROUPE</td>
	<!--<td class="tab_dis_head">ACTION</td>
	<td class="tab_dis_head">MANAGER</td>
	<td class="tab_dis_head">EMAIL</td>
	<td class="tab_dis_head">FONCTION</td>
	<td class="tab_dis_head">ZONE</td>
	<td class="tab_dis_head">RESEAU</td>
--></tr>

<?php 
$t_man=array();
while($r = mysql_fetch_object($res)){
	
	
	//$t_man = explode (",",getManagernameById(getIdManagerByDis($r->id)));
	
?>	

<tr>
	<td class="tab_dis_data"><a href="man_details.php?codesap=<?php echo $r->codesap;?>&cur=13"><?php echo $r->codesap;?></a></td>
	<td class="tab_dis_data"><?php echo $r->nom;?></td>
	<td class="tab_dis_data"><?php echo $r->groupe;?></td>
	<!--<td class="tab_dis_data"><a href="dis_contacts.php?cur=3&action=mod_dis_new&id_dis=<?php echo $r->id;?>">Modifier</a> / <a href="controler.php?action=sup_dis&id=<?php echo $r->id;?>">Supprimer</a></td>
	<td class="tab_dis_data"><?php echo "$t_man[0] $t_man[1] "; ?></td>
	<td class="tab_dis_data"><?php echo "$t_man[2]" ;?></td>
	<td class="tab_dis_data"><?php  echo "$t_man[3]" ;?></td>
	<td class="tab_dis_data"><?php echo $valz = getZoneNameById($r->id_zone);?></td>
	<td class="tab_dis_data"><?php echo $valr = getReseauNameById($r->id_reseau);?></td>
--></tr>
<?php }?>

</table>

</form>
</body>

</html>
